from typing import Any

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.func import entrypoint

checkpointer = InMemorySaver()
@entrypoint(checkpointer=checkpointer)
def my_workflow(number: int, *, previous: Any = None) -> int:
    previous = previous or 0
    return number + previous

config = {
    "configurable": {
        "thread_id": "some_thread_id"
    }
}

if __name__ == '__main__':
    checkpointer = InMemorySaver()
    print(my_workflow.invoke(3, config))  # 1 (previous was None)
    print(my_workflow.invoke(0, config))